Skip to content

fix: 멘토 지원서 승인 시 유저 Role 을 Mentor로 승격#639

Open
sukangpunch wants to merge 5 commits intosolid-connection:developfrom
sukangpunch:fix/636-change-role-to-mentor-after-approval
Open

fix: 멘토 지원서 승인 시 유저 Role 을 Mentor로 승격#639
sukangpunch wants to merge 5 commits intosolid-connection:developfrom
sukangpunch:fix/636-change-role-to-mentor-after-approval

Conversation

@sukangpunch
Copy link
Contributor

관련 이슈

작업 내용

어드민에서 멘토 지원서를 승인 할 때, 유저의 Role 을 Mentor 로 승격하도록 기능을 수정하였습니다.

특이 사항

리뷰 요구사항 (선택)

@sukangpunch sukangpunch self-assigned this Feb 2, 2026
@sukangpunch sukangpunch added the 버그 Something isn't working label Feb 2, 2026
@sukangpunch sukangpunch requested a review from JAEHEE25 as a code owner February 2, 2026 12:25
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

Walkthrough

  1. AdminMentorApplicationService: 멘토 신청 승인 흐름에 멘토 엔티티 생성 로직과 MentorRepository 주입을 추가했습니다.
  2. AdminMentorApplicationService: 승인 시 SiteUser 조회, validateUserCanCreateMentor 검증, SiteUser.becomeMentor 호출, Mentor 엔티티 생성 및 저장 로직이 추가되었습니다.
  3. SiteUser 도메인: 사용자의 역할을 MENTOR로 변경하는 public 메서드 becomeMentor()를 추가했습니다.
  4. AdminMentorApplicationServiceTest: SiteUserRepository·MentorRepository 주입 및 승인 후 SiteUser 역할과 Mentor 생성 유효성 검사를 추가하고, 이미 멘토가 존재할 경우 MENTOR_ALREADY_EXISTS 예외 테스트를 추가했습니다.
  5. MentorMyPageController: 멘토 마이페이지 생성 POST 엔드포인트와 관련 요청 DTO 임포트를 삭제했습니다.
  6. Mentor 도메인: introductionpassTip 컬럼을 nullable로 변경하고 createChannels 메서드를 제거했습니다.
  7. MentorMyPageCreateRequest DTO: 해당 레코드를 삭제했습니다.
  8. MentorMyPageService: createMentorMyPage 공개 API를 제거하고, 업데이트 로직에서 채널 빌드 호출을 인라인화하며 관련 헬퍼 제거를 적용했습니다.
  9. DB 마이그레이션: mentor.introduction 및 mentor.pass_tip 컬럼을 NULL 허용으로 변경하는 V44 마이그레이션을 추가했습니다.
  10. MentorMyPageServiceTest: 멘토 생성 관련 테스트 클래스와 테스트들을 삭제하여 생성 워크플로우 관련 테스트가 제거되었습니다.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • wibaek
  • Hexeong
  • JAEHEE25
  • lsy1307
  • Gyuhyeok99
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 멘토 생성 API 제거, DTO 삭제, 필드 nullable 변경 등 일부 변경사항이 #636의 주요 목표 범위를 벗어났습니다. 멘토 지원서 승인 시 역할 승격과 직접 관련 없는 변경사항(createMentorMyPage API 제거, 필드 nullable 변경)을 별도 PR로 분리하거나 명확히 정당화해주세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 멘토 지원서 승인 시 유저 Role을 Mentor로 승격하는 메인 변경사항을 명확하고 간결하게 설명합니다.
Description check ✅ Passed PR 설명은 필수 항목인 관련 이슈(#636), 작업 내용을 완성했으나, 특이 사항과 리뷰 요구사항은 미작성된 상태입니다.
Linked Issues check ✅ Passed PR의 모든 코드 변경사항이 #636의 목표(멘토 지원서 승인 후 사용자 role을 Mentor로 변경)를 충족합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@whqtker whqtker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 ~!

다만 현재는 siteUserroleMENTOR 로 변경하는 거 같은데, mentor 엔티티 또한 생성해야 합니다 ! 이후 관련하여 테스트(승인하면 멘토 생성)도 추가해주시면 좋겠습니다 !!

@sukangpunch sukangpunch closed this Feb 3, 2026
@sukangpunch sukangpunch reopened this Feb 3, 2026
@sukangpunch
Copy link
Contributor Author

고생하셨습니다 ~!

다만 현재는 siteUserroleMENTOR 로 변경하는 거 같은데, mentor 엔티티 또한 생성해야 합니다 ! 이후 관련하여 테스트(승인하면 멘토 생성)도 추가해주시면 좋겠습니다 !!

알겠습니다!

- not null 인 필드에 빈문자열로 값을 채우는 것 보다, null 허용이 더 의미
  있다 판단하여 null 을 허용하도록 하였습니다.
- 멘토 생성의 주체가 어드민으로 변경되어 Mentor 도메인의 Mentor 생성 api 를 제거
- 중복 멘토 생성 예외 처리 및 테스트 추가
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java (1)

40-40: ⚠️ Potential issue | 🟡 Minor

사용하지 않는 mentorApplicationRepository 의존성을 제거하세요.

createMentorMyPage 메서드가 제거되면서 이 클래스 내에서 mentorApplicationRepository를 참조하는 코드가 더 이상 없습니다. 불필요한 의존성은 정리하는 것이 좋습니다.

  1. import 제거 (15번 줄)
  2. 필드 주입 제거 (40번 줄)
정리할 코드
-import com.example.solidconnection.mentor.repository.MentorApplicationRepository;
     private final MentorRepository mentorRepository;
     private final SiteUserRepository siteUserRepository;
     private final HostUniversityRepository hostUniversityRepository;
     private final TermRepository termRepository;
-    private final MentorApplicationRepository mentorApplicationRepository;
🧹 Nitpick comments (2)
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java (1)

56-68: 생성자의 universityId 파라미터 타입 불일치에 주의하세요.

  1. 생성자 파라미터는 Long universityId (박싱 타입, line 60)인데, 필드는 long universityId (원시 타입, line 46)입니다.
  2. 만약 null이 전달되면 auto-unboxing 시 NullPointerException이 발생합니다.

학습된 비즈니스 규칙에 따르면 APPROVED 상태의 MentorApplication은 항상 non-null universityId를 가지므로 현재 흐름에서는 문제가 없지만, 방어적 코딩 관점에서 파라미터 타입을 long으로 통일하거나, null 체크를 추가하는 것을 고려해 주세요. Based on learnings, APPROVED 상태의 MentorApplication은 항상 non-null universityId를 가진다는 비즈니스 규칙이 있습니다.

💡 파라미터 타입 통일 제안
     public Mentor(
             String introduction,
             String passTip,
             long siteUserId,
-            Long universityId,
+            long universityId,
             long termId
     ) {
src/main/java/com/example/solidconnection/admin/service/AdminMentorApplicationService.java (1)

48-67: 멘토 생성 로직이 잘 구현되어 있습니다. 다만 검증 순서를 개선하면 더 안전합니다.

현재 흐름:

  1. mentorApplication.approve() (상태 변경) → line 51
  2. validateUserCanCreateMentor() (중복 검증) → line 55

트랜잭션 롤백으로 인해 실제 데이터 무결성 문제는 없지만, approve() 이전에 모든 사전 검증을 완료하는 것이 방어적 프로그래밍 관점에서 더 안전합니다. 만약 향후 approve() 내부에 이벤트 발행 등의 부수 효과가 추가된다면, 롤백만으로는 충분하지 않을 수 있습니다.

🔄 검증 순서 변경 제안
     `@Transactional`
     public void approveMentorApplication(Long mentorApplicationId) {
         MentorApplication mentorApplication = mentorApplicationRepository.findById(mentorApplicationId)
                 .orElseThrow(() -> new CustomException(MENTOR_APPLICATION_NOT_FOUND));
-        mentorApplication.approve();
 
         SiteUser siteUser = siteUserRepository.findById(mentorApplication.getSiteUserId())
                 .orElseThrow(() -> new CustomException(USER_NOT_FOUND));
         validateUserCanCreateMentor(siteUser.getId());
 
+        mentorApplication.approve();
         siteUser.becomeMentor();
         Mentor mentor = new Mentor(
                 null,
                 null,
                 siteUser.getId(),
                 mentorApplication.getUniversityId(),
                 mentorApplication.getTermId()
         );
 
         mentorRepository.save(mentor);
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

버그 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 멘토 지원서 승인 시 사용자 role을 MENTOR로 변경하도록 수정

2 participants